//
//  HomeMainViewController.m
//  SHHCPhone
//
//  Created by sheng long on 14-6-19.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "HomeMainViewController.h"
#import "HomeWeightView.h"
#import "SettingViewController.h"
#import "BodyCompositionViewController.h"
#import "HomeFloatLayerView.h"
#import "BluetoothManager.h"
#import "BodyIngredientViewController.h"
#import "HomeSideViewController.h"
#import "ConsultViewController.h"
#import "WeightReferenceViewController.h"
#import "HotAskViewController.h"

@interface HomeMainViewController ()
{
    BOOL isFirst;
    
    //设置setDataDic的时候是否需要执行画体重
    BOOL isPaint;
    
    //主页面
    UIScrollView *mainScroll;
    
    //浮层
    HomeFloatLayerView *floatLayerView;
    
    //蓝牙管理
    BluetoothManager *bluetoothManager;
    
    //怀孕周期
    UILabel *periodLabel;
    
    //体重显示
    UIView *tzView;
    UILabel *weightLabel;
    UILabel *kgLabel;
    
    //记录时间
    UILabel *timeLabel;
    
    //画体重页面
    HomeWeightView *weightView;
    
    //首页下面4个Label数组
    NSArray *viewArray;
    //接口返回的对应参数名称
    NSArray *paramArray;
    
    //连接蓝牙button
    UIButton *connectButton;
}

@property (nonatomic,retain) NSDictionary *dataDic;

@end

@implementation HomeMainViewController

@synthesize dataDic;

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter ] removeObserver:self];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    bluetoothManager = [[BluetoothManager alloc] init];
    bluetoothManager.showInBaseView = self;
    APP_BLUEMANAGER = bluetoothManager;
    
    [[NSNotificationCenter defaultCenter ] addObserver:self selector:@selector(ljsbcg:) name:BLUETOOTHMANAGER_LJSBCG object:nil];
    [[NSNotificationCenter defaultCenter ] addObserver:self selector:@selector(ljsbsb) name:BLUETOOTHMANAGER_LJSBSB object:nil];
    [[NSNotificationCenter defaultCenter ] addObserver:self selector:@selector(jssbsj:) name:BLUETOOTHMANAGER_JSSBSJ object:nil];
    
    [navigationBarView setTitle:@"首页"];
    [navigationBarView setNormalLeftMenuButton];
    [navigationBarView setNormalRightButton];
    
    mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NAVIGATIONBAR_HEIGHT, CURRENT_CONTENT_WIDTH, CURRENT_CONTENT_HEIGHT-NAVIGATIONBAR_HEIGHT)];
    [mainScroll setShowsHorizontalScrollIndicator:NO];
    [mainScroll setShowsVerticalScrollIndicator:NO];
    [mainScroll setBounces:NO];
    [self.view addSubview:mainScroll];
    
    /*      体重显示View    */
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mainScroll.frame.size.width, 225)];
    [view setBackgroundColor:GET_COLOR(@"f0f0f0")];
    [mainScroll addSubview:view];
    
    //画体重
    weightView = [[HomeWeightView alloc] initWithFrame:CGRectMake(0, 0, 180, 180)];
    [mainScroll addSubview:weightView];
    [weightView setBackgroundColor:[UIColor clearColor]];
    [weightView setCenter:CGPointMake(CURRENT_CONTENT_WIDTH/2, 13+weightView.frame.size.height/2)];
    
    //周期
    periodLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, weightView.frame.origin.y+45, CURRENT_CONTENT_WIDTH, 17)];
    [periodLabel setTextColor:[UIColor whiteColor]];
    [periodLabel setBackgroundColor:[UIColor clearColor]];
    [mainScroll addSubview:periodLabel];
    [periodLabel setTextAlignment:NSTextAlignmentCenter];
    [periodLabel setFont:[UIFont systemFontOfSize:11]];
    
    //体重显示view
    tzView = [[UIView alloc]initWithFrame:CGRectZero];
    [tzView setBackgroundColor:[UIColor clearColor]];
    [mainScroll addSubview:tzView];
    
    kgLabel = [[UILabel alloc] initWithFrame:CGRectMake(weightView.frame.size.width+weightView.frame.origin.x-57, periodLabel.frame.size.height+periodLabel.frame.origin.y+32, 20, 14.5)];
    [kgLabel setTextColor:[UIColor whiteColor]];
    [kgLabel setBackgroundColor:[UIColor clearColor]];
    [tzView addSubview:kgLabel];
    [kgLabel setTextAlignment:NSTextAlignmentCenter];
    [kgLabel setFont:[UIFont systemFontOfSize:12]];
    
    weightLabel = [[UILabel alloc] initWithFrame:CGRectMake(kgLabel.frame.origin.x-150, kgLabel.frame.size.height+kgLabel.frame.origin.y-41, 150, 48)];
    [weightLabel setTextColor:[UIColor whiteColor]];
    [weightLabel setBackgroundColor:[UIColor clearColor]];
    [tzView addSubview:weightLabel];
    [weightLabel setFont:[UIFont systemFontOfSize:40]];
    [weightLabel setTextAlignment:NSTextAlignmentRight];
    
    //时间
    timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, kgLabel.frame.origin.y+kgLabel.frame.size.height+10, CURRENT_CONTENT_WIDTH, 14.5)];
    [timeLabel setTextColor:[UIColor whiteColor]];
    [timeLabel setBackgroundColor:[UIColor clearColor]];
    [mainScroll addSubview:timeLabel];
    [timeLabel setTextAlignment:NSTextAlignmentCenter];
    [timeLabel setFont:[UIFont systemFontOfSize:11]];
    
    UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(0, weightView.frame.origin.y+weightView.frame.size.height+12, CURRENT_CONTENT_WIDTH, 12.5)];
    [label5 setText:@"未检测到健康仪，点击       进行连接"];
    [label5 setTextColor:GET_COLOR(@"969696")];
    [label5 setBackgroundColor:[UIColor clearColor]];
    [mainScroll addSubview:label5];
    [label5 setTextAlignment:NSTextAlignmentCenter];
    [label5 setFont:[UIFont systemFontOfSize:12]];
    
    connectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [connectButton setImage:[UIImage imageNamed:@"首页-链接icon.png"] forState:UIControlStateNormal];
    [connectButton setFrame:CGRectMake(179, weightView.frame.origin.y+weightView.frame.size.height+1, 35, 35)];
    [mainScroll addSubview:connectButton];
    [connectButton addTarget:self action:@selector(connectButt) forControlEvents:UIControlEventTouchUpInside];
    
    /*      身体成分显示View    */
    NSArray *dArray = @[@[@"体成分-肌肉率icon.png",@"肌肉量"],@[@"体成分-水分icon.png",@"水分"],@[@"首页-体脂率icon.png",@"体脂率"],@[@"首页-BMIicon.png",@"BMI"]];
    NSMutableArray *vArray = [NSMutableArray arrayWithCapacity:1];
    for (int i = 0 ; i < dArray.count ; i++) {
        
        NSInteger x = i%2;
        NSInteger y = i/2;
        
        UIView *menuView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mainScroll.frame.size.width/2, 105)];
        [menuView setBackgroundColor:[UIColor clearColor]];
        [mainScroll addSubview:menuView];
        [menuView setCenter:CGPointMake(mainScroll.frame.size.width/2*x+menuView.frame.size.width/2, view.frame.size.height+view.frame.origin.y+menuView.frame.size.height/2+menuView.frame.size.height*y)];
        
        NSArray *array = [dArray objectAtIndex:i];
        
        UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[array objectAtIndex:0]]];
        [image sizeToFit];
        [image setCenter:CGPointMake(menuView.frame.size.width/2, 20+image.frame.size.height/2)];
        [menuView addSubview:image];
        
        UILabel *label6 = [[UILabel alloc] initWithFrame:CGRectZero];
        [label6 setText:[array objectAtIndex:1]];
        [label6 setTextColor:GET_COLOR(@"fea9c7")];
        [label6 setBackgroundColor:[UIColor clearColor]];
        [menuView addSubview:label6];
        [label6 setFont:[UIFont systemFontOfSize:14]];
        [label6 sizeToFit];
        [label6 setCenter:CGPointMake(image.center.x, image.frame.size.height+image.frame.origin.y+5+label6.frame.size.height/2)];
        
        //        UILabel *label7 = [[UILabel alloc] initWithFrame:CGRectZero];
        UILabel *label7 = [[UILabel alloc] initWithFrame:CGRectMake(0, label6.frame.size.height+label6.frame.origin.y+5, menuView.frame.size.width, 14.5)];
        //        [label7 setText:[array objectAtIndex:2]];
        [label7 setTextAlignment:NSTextAlignmentCenter];
        [label7 setTextColor:GET_COLOR(@"969696")];
        [label7 setBackgroundColor:[UIColor clearColor]];
        [menuView addSubview:label7];
        [label7 setFont:[UIFont systemFontOfSize:12]];
        [vArray addObject:label7];
        //        [label7 sizeToFit];
        //        [label7 setCenter:CGPointMake(image.center.x, label6.frame.size.height+label6.frame.origin.y+5+label7.frame.size.height/2)];
        
        UIButton *menuButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [menuButton setTag:i];
        [menuButton addTarget:self action:@selector(menuButt:) forControlEvents:UIControlEventTouchUpInside];
        [menuButton setFrame:menuView.bounds];
        [menuView addSubview:menuButton];
    }
    viewArray = vArray;
    
    //间隔线
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, view.frame.size.height+view.frame.origin.y+105, mainScroll.frame.size.width, .5)];
    [mainScroll addSubview:view2];
    [view2 setBackgroundColor:GET_COLOR(@"969696")];
    [view2 setAlpha:.4];
    
    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(mainScroll.frame.size.width/2, view.frame.size.height+view.frame.origin.y+20, .5, 105*2-20*2)];
    [mainScroll addSubview:view3];
    [view3 setBackgroundColor:GET_COLOR(@"969696")];
    [view3 setAlpha:.4];
    
    /*      进入下个页面View    */
    NSArray *iArray = @[@"首页-底部按钮-左侧icon.png",@"首页-底部按钮-右侧icon.png"];
    NSArray *zArray = @[@"称重之后快来看看深度体成分分析吧",@"营养问题？快来咨询我们的营养师"];
    for (int i = 0 ; i < iArray.count; i++) {
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [button1 setBackgroundImage:[UIImage imageNamed:@"首页-底部按钮-背景.png"] forState:UIControlStateNormal];
        [button1 setBackgroundImage:[UIImage imageNamed:@"首页-底部按钮-背景-点击.png"] forState:UIControlStateHighlighted];
        [button1 sizeToFit];
        [button1 setCenter:CGPointMake((CURRENT_CONTENT_WIDTH-button1.frame.size.width*2)/3*(i+1)+button1.frame.size.width*(i+0.5), weightView.frame.origin.y+weightView.frame.size.height+250+button1.frame.size.height/2)];
        [button1 setTag:i];
        [mainScroll addSubview:button1];
        [button1 addTarget:self action:@selector(pushButt:) forControlEvents:UIControlEventTouchUpInside];
        
        UIImageView *image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[iArray objectAtIndex:i]]];
        [image1 sizeToFit];
        [image1 setCenter:CGPointMake(4+image1.frame.size.width/2,button1.frame.size.height/2)];
        [button1 addSubview:image1];
        
        UILabel *label7 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image1.frame)+4, 0, button1.frame.size.width-CGRectGetMaxX(image1.frame)-4*2, button1.frame.size.height)];
        [label7 setText:[zArray objectAtIndex:i]];
        [label7 setTextColor:[UIColor whiteColor]];
        [label7 setBackgroundColor:[UIColor clearColor]];
        [button1 addSubview:label7];
        [label7 setFont:[UIFont boldSystemFontOfSize:13]];
        [label7 setNumberOfLines:0];
        
        [mainScroll setContentSize:CGSizeMake(0, button1.frame.size.height+button1.frame.origin.y+10)];
    }
    
    /*      浮层显示iew    */
    floatLayerView = [[HomeFloatLayerView alloc] initWithFrame:self.view.bounds];
    [floatLayerView setAlpha:0];
    [floatLayerView setBaseVc:self];
    [self.view addSubview:floatLayerView];
    
    //点击进入体重管理页面
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundColor:[UIColor clearColor]];
    [button setFrame:weightView.frame];
    [mainScroll addSubview:button];
    [button addTarget:self action:@selector(tzManage) forControlEvents:UIControlEventTouchUpInside];
    
    //
    paramArray = @[@"muscle_rate",@"total_body_water",@"fat_percentage",@"bmi"];
    
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if (!isFirst) {
        
        isFirst = YES;
        
        if (!CURRENT_VERSION_SEVEN) {
            //7以下加载2个navigationController会出现多20的空隙，需执行此方法
            [self.mm_drawerController setCenterViewController:self.navigationController withCloseAnimation:NO completion:nil];
        }
        
        [LoadingFrameView showLoadingview];
    
        ASIHTTPRequest *request = [self getData];
        [self.netArray addObject:request];
        [self superASIStartAsynchronous:request];
    }
}

-(ASIHTTPRequest*)getData
{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:IOS_INDEX forKey:IOS_METHOD_NAME];
    [dic setValue:APP_USER_MSG.id forKey:@"user_id"];
    
    ASIHTTPRequest *request =  [NetUtls httpGet:self withValue:dic tag:IOS_INDEX_TAG need:NO];
    return request;
}

//显示对于浮层
-(void)menuButt:(UIButton*)button
{
    if (dataDic) {
        NSDictionary *dic = [[dataDic objectForKey:@"layerInfo"] objectForKey:[paramArray objectAtIndex:button.tag]];
        [floatLayerView setContent:@[[NSString stringWithFormat:@"%@",[dic valueForKey:@"min"]],[NSString stringWithFormat:@"%@",[dic valueForKey:@"max"]]] tip:[dic valueForKey:@"text"]];
    }
}

//设置数据源，一般获取的网络数据
-(void)setDataDic:(NSDictionary *)dDic
{
    dataDic = nil;
    dataDic = [NSDictionary dictionaryWithDictionary:dDic];
    
    //显示孕周和最后一次测量时间
    NSDictionary *dic = [dataDic valueForKey:@"basicInfo"];
    [periodLabel setText:[NSString stringWithFormat:@"孕期%@周",[dic valueForKey:@"week"]]];
    
    NSString *updateTime = [dic valueForKey:@"update_time"];
    if (updateTime.length > 0) {
//        NSString *time = [z_DateTime timeSinceNow:[z_DateTime dencodeTime:updateTime format:@"yyyy-MM-dd HH:mm:ss"]];
//        CLog(@"==%@",[z_DateTime dencodeTime:updateTime format:@"yyyy-MM-dd HH:mm:ss"]);
        NSString *time = [z_DateTime encodeTime:[z_DateTime dencodeTime:updateTime format:@"yyyy-MM-dd HH:mm:ss"] format:@"MM-dd HH:mm"];
        [timeLabel setText:time];
    }else{
        [timeLabel setText:nil];
    }
    
    //显示体成分
    NSDictionary *lastDic = [dataDic valueForKey:@"lastRecord"];
    NSMutableArray *result = [NSMutableArray arrayWithCapacity:1];
    if (lastDic.count) {
        for (int i = 0 ; i < paramArray.count; i++) {
            NSString *text = [paramArray objectAtIndex:i];
            if ([lastDic valueForKey:text]) {
                [result addObject:[lastDic valueForKey:text]];
            }else if ([text isEqualToString:@"bmi"]){
                [result addObject:@"0"];
            }
        }
    }
    [self showSTComposition:result];
    
    if (!isPaint) {
        return;
    }

    //记录的数据
    NSString *weight = [lastDic valueForKey:@"weight"];
    if ([weight isKindOfClass:[NSString class]]) {
        if (weight.length > 0) {
            [self showWeight:weight];
            return;
        }
    }
    [self showWeight:@"0"];
}

//显示体重
-(void)showWeight:(NSString *)weight
{
    //保留一位小数
    weight = [NSString stringWithFormat:@"%.1f",weight.floatValue];
    
    CGFloat textSize = 0;
    if (weight.length <= 4) {
        textSize = 45;
    }else if(weight.length == 5){
        textSize = 40;
    }else{
        textSize = 33;
    }
    
    //记录的数据
    if (weight.floatValue>0) {
        CLog(@"画体重");
        [weightView setMySize:[weight floatValue]];
    }
    [weightLabel setFont:[UIFont systemFontOfSize:textSize]];
    [weightLabel setText:weight];
    [kgLabel setText:APP_WEIGHT_UNIT];
    
    [weightLabel sizeToFit];
    [kgLabel sizeToFit];
    
    //
    [tzView setFrame:CGRectMake(0, 0, weightLabel.frame.size.width+kgLabel.frame.size.width, MAX(weightLabel.frame.size.height, kgLabel.frame.size.height))];
    [weightLabel setCenter:CGPointMake(weightLabel.frame.size.width/2, tzView.frame.size.height/2)];
    [kgLabel setCenter:CGPointMake(tzView.frame.size.width-kgLabel.frame.size.width/2, tzView.frame.size.height-kgLabel.frame.size.height/2-5)];
    
    [tzView setCenter:weightView.center];
}

//显示身体成分
-(void)showSTComposition:(NSArray*)array
{
    NSArray *dwArray = @[APP_WEIGHT_UNIT,APP_WEIGHT_UNIT,@"%",[NSString stringWithFormat:@"%@/m²",APP_WEIGHT_UNIT]];
    for (int i = 0 ; i < array.count; i++) {
        UILabel *label = (UILabel*)[viewArray objectAtIndex:i];
        [label setText:[NSString stringWithFormat:@"%@%@",[array objectAtIndex:i],[dwArray objectAtIndex:i]]];
    }
}

-(void)connectButt
{
    CLog(@"连接");
    [bluetoothManager connectCBManager];
}

-(void)pushButt:(UIButton*)button
{
    CLog(@"进入详情");
    NSArray *array = AppDelegate_A.leftVCArray;
    if (button.tag) {
        //营养咨询
        for (UIViewController *vc in array) {
            if ([vc isKindOfClass:[HotAskViewController class]]) {
                HotAskViewController *view = (HotAskViewController*)vc;
                view.showBackBtn = YES;
                [self.navigationController pushViewController:view animated:YES];
                break;
            }
        }
    }else{
        for (UIViewController *vc in array) {
            if ([vc isKindOfClass:[BodyIngredientViewController class]]) {
                BodyIngredientViewController *view = (BodyIngredientViewController*)vc;
                view.showBackBtn = YES;
                view.vcArray = array;
                [self.navigationController pushViewController:view animated:YES];
                break;
            }
        }
    }
}

//进入体重管理
-(void)tzManage
{
    [self.navigationController pushViewController:[[WeightReferenceViewController alloc]init] animated:YES];
}

#pragma mark - 蓝牙设备通知
-(void)ljsbcg:(NSNotification*)note
{
    CLog(@"note==%@",note.userInfo);
    
    [connectButton setEnabled:NO];
    
    //连接设备成功
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, weightView.frame.origin.y+weightView.frame.size.height+12, CURRENT_CONTENT_WIDTH, 12.5)];
    [mainScroll addSubview:label];
    [label setTag:4634];
    [label setText:[NSString stringWithFormat:@"成功连接上设备%@",[note.userInfo valueForKey:@"name"]]];
    [label setTextColor:GET_COLOR(@"969696")];
    [label setBackgroundColor:GET_COLOR(@"f0f0f0")];
    [label setTextAlignment:NSTextAlignmentCenter];
    [label setFont:[UIFont systemFontOfSize:12]];
}

-(void)ljsbsb
{
    //连接设备失败
    [[mainScroll viewWithTag:4634] removeFromSuperview];
    [connectButton setEnabled:YES];
}

-(void)jssbsj:(NSNotification*)note
{
    //接收设备数据
    NSArray *array = [note.userInfo valueForKey:@"data"];
    [self showWeight:[array objectAtIndex:0]];
    
    //显示测量时间
    [timeLabel setText:[z_DateTime encodeTime:[NSDate date] format:@"MM-dd HH:mm"]];
    
    //显示体成分
    NSMutableArray *result = [NSMutableArray arrayWithCapacity:1];
    [result addObject:[array objectAtIndex:5]];
    [result addObject:[array objectAtIndex:3]];
    [result addObject:[array objectAtIndex:2]];
    [result addObject:@"0"];
    [self showSTComposition:result];
    
    //上传数据
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:1];
    [dic setValue:IOS_UPLOAD forKey:IOS_METHOD_NAME];
    [dic setValue:APP_USER_MSG.id forKey:@"user_id"];
    
    NSArray *nameArray = @[@"weight",@"fat_weight",@"fat_percentage",@"total_body_water",@"extracellular_fluid",@"muscle_rate",@"protein",@"mineral",@"basal_metabolism",];
    for (int i = 0 ; i < nameArray.count; i++) {
        [dic setValue:[array objectAtIndex:i] forKey:[nameArray objectAtIndex:i]];
    }
    
    //是否存在本地数据
    NSString *local = [self getLocalData];
    if (local) {
        //替换本地数据
        NSMutableDictionary *oldDic = [NSMutableDictionary dictionaryWithDictionary:[local objectFromJSONString]];
       
        NSMutableDictionary *lastRecord = nil;
        
        if ([[oldDic objectForKey:@"lastRecord"] isKindOfClass:[NSDictionary class]]) {
            lastRecord = [NSMutableDictionary dictionaryWithDictionary:[oldDic objectForKey:@"lastRecord"]];
            NSArray *array1 = dic.allKeys;
            for (int i = 0; i < array1.count; i++) {
                NSString *key = [array1 objectAtIndex:i];
                if ([lastRecord valueForKey:key]) {
                    CLog(@"%@",lastRecord);
                    [lastRecord setValue:[dic valueForKey:key] forKey:key];
                }
            }
        }else{
            lastRecord = [NSMutableDictionary dictionaryWithDictionary:dic];
        }
        [oldDic setObject:lastRecord forKey:@"lastRecord"];
        CLog(@"JSONString====%@",[oldDic JSONString]);
        [self saveLocalData:[oldDic JSONString]];
    }else{
        NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithCapacity:1];
        [dic1 setObject:dic forKey:@"lastRecord"];
        [self saveLocalData:[dic1 JSONString]];
    }
    
    //上传数据
    ASIHTTPRequest *request =  [NetUtls httpGet:self withValue:dic tag:IOS_UPLOAD_TAG need:NO];
    [self.netArray addObject:request];
    [request startAsynchronous];
}

#pragma mark - ASIHTTPRequestDelegate
-(void)requestFinished:(ASIHTTPRequest *)request
{
    CLog(@"%@",[request responseString]);
    if (request.tag == IOS_UPLOAD_TAG) {
        ASIHTTPRequest *request = [self getData];
        request.userInfo = @{@"123": @"123"};
        [self.netArray addObject:request];
        [self superASIStartAsynchronous:request];
    }
}

-(void)requestFailed:(ASIHTTPRequest *)request
{
    if (request.tag == IOS_UPLOAD_TAG) {
        return;
    }

    [LoadingFrameView directlyDisappear];

    //是否存在本地数据
    NSString *local = [self getLocalData];
    if (local) {
        isPaint = YES;
        self.dataDic = [local objectFromJSONString];
    }
}

//父类获取服务器返回信息，成功获取到数据执行方法
-(void)getASIRecordSucceed:(ASIHTTPRequest *)request data:(NSDictionary*)dic
{
    if (request.userInfo) {
        isPaint = NO;
        CLog(@"request.userInfo有值");
    }else{
        isPaint = YES;
        CLog(@"request.userInfo没有值");
    }
    
    self.dataDic = dic;
    [LoadingFrameView directlyDisappear];
    [self saveLocalData:[dic JSONString]];
}

//父类获取服务器返回信息，未成功获取到数据执行方法
-(void)getASIRecordFailed:(ASIHTTPRequest *)request data:(NSString*)failed
{
    CLog(@"错误信息===%@",failed);

    [LoadingFrameView directlyDisappear];
}

@end
